﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using AtentoFramework2008.TestTools.DomainModel;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NHibernate.Type;
using NStore.Domain;

namespace NStore.Infrastructure.Tests.MappingFile
{
    [TestClass]
    public class UserTest
    {
        [TestMethod]
        public void ShouldBePersistent()
        {
            SpecifyOn.Entity<User>().ShouldBePersistent().MappedToTable("Users");
        }

        [TestMethod]
        public void Id_IsIdentifierProperty()
        {
            SpecifyOn.Entity<User>().ShouldHaveProperty("Id").ShouldBePersistent()
                .MappedToColumn("Id")
                .MappedWithPropertyAccessorName("field.camelcase-underscore")
                .MappedWithIdentifierProperty();
        }

        [TestMethod]
        public void Name_ShouldBePersistent()
        {
            SpecifyOn.Entity<User>().ShouldHaveProperty("UserName").ShouldBePersistent()
                .MappedToColumn("UserName")
                .MappedWithPropertyAccessorName("field.camelcase-underscore")
                .MappedWithLength(50)
                .MappedWithUnique()
                .MappedWithType<StringType>();
        }

        [TestMethod]
        public void Password_ShouldBePersistent()
        {
            SpecifyOn.Entity<User>().ShouldHaveProperty("Password").ShouldBePersistent()
                .MappedToColumn("Password")
                .MappedWithPropertyAccessorName("field.camelcase-underscore")
                .MappedWithLength(50)
                .MappedWithType<StringType>();
        }

        [TestMethod]
        public void PasswordSalt_ShouldBePersistent()
        {
            SpecifyOn.Entity<User>().ShouldHaveProperty("PasswordSalt").ShouldBePersistent()
                .MappedToColumn("PasswordSalt")
                .MappedWithPropertyAccessorName("field.camelcase-underscore")
                .MappedWithLength(50)
                .MappedWithType<StringType>();
        }

        [TestMethod]
        public void Email_ShouldBePersistent()
        {
            SpecifyOn.Entity<User>().ShouldHaveProperty("Email").ShouldBePersistent()
                .MappedToColumn("Email")
                .MappedWithLength(80)
                .MappedWithType<StringType>();
        }

        [TestMethod]
        public void Roles_ShouldBePersistent()
        {
            SpecifyOn.Entity<User>().ShouldHaveProperty("Roles").ShouldBePersistent();
        }
    }
}
